package om.jenkinslog;

import om.Utils.EsClientUtils;
import om.Utils.HttpClientUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author xiazhonghai
 * @date 2021/1/26 14:03
 * @description:
 */
public class Common {
    static Properties properties = new Properties();
    static CloseableHttpClient httpclient;
     RestHighLevelClient esClient;
     BulkProcessor bulkProcess;
     {
        httpclient = HttpClientUtils.getClient();
         InputStream resourceAsStream = JenkinsLog.class.getClassLoader().getResourceAsStream("config.properties");
         try {
            properties.load(resourceAsStream);
            esClient= EsClientUtils.getEsClient();
             bulkProcess = EsClientUtils.getBulkProcess(esClient);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
             try {
                 resourceAsStream.close();
             } catch (IOException e) {
                 e.printStackTrace();
             }
         }


    }
}
